#include "stdafx.h"
#include "PerformanceDataStore.h"


/*virtual*/void CPerformanceDataStore::AddPerformanceData(const wchar_t* szwDescription, double elapsedTime)
{
	this->keyValue.insert(std::pair<std::wstring, double>(szwDescription, elapsedTime));
}

/*virtual*/bool CPerformanceDataStore::TryGetDouble(const wchar_t* szwDescription, double* pDbl)
{
	auto it = this->keyValue.find(szwDescription);
	if (it != this->keyValue.end())
	{
		if (pDbl != nullptr)
		{
			*pDbl = it->second;
		}

		return true;
	}

	return false;
}

/*virtual*/ void CPerformanceDataStore::EnumDescriptions(std::function<bool(const std::wstring&)> func)
{
	for (const auto &pair : this->keyValue)
	{
		bool b = func(pair.first);
		if (b == false)
		{
			break;
		}
	}
}

/*virtual*/void CPerformanceDataStore::Clear()
{
	this->keyValue.clear();
}
